package com.keming.dao;

import com.keming.pojo.Picture;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
@Repository
public interface PictureDao {
    //查询照片
    @Select("select * from myblog.t_picture order by t_picture.id desc")
    List<Picture> listPicture();

    //添加图片
    @Insert("insert into myblog.t_picture (picturename,picturetime,pictureaddress,picturedescription) values (#{picturename},#{picturetime},#{pictureaddress},#{picturedescription})")
    int savePicture(Picture picture);
    //根据id查询照片
    @Select("select * from myblog.t_picture p where p.id = #{id}")
    Picture getPicture(Long id);

    //编辑修改相册
    @Update("update myblog.t_picture set picturename = #{picturename}, picturetime = #{picturetime}, pictureaddress = #{pictureaddress}, picturedescription = #{picturedescription} where id = #{id}")
    int updatePicture(Picture picture);

    //删除照片
    @Delete("delete from myblog.t_picture where id = #{id}")
    void deletePicture(Long id);
}
